package com.atguigu.exam;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

/**
 * 编写一个应用程序，将用户从键盘输入的10个整数存入文件，再顺序读出。
 * @author xbd
 * @create 2021-05-30 22:31
 */
public class IntegerTest {
    public static void main(String[] args) {
        BufferedWriter bw = null;
        Scanner scanner = null;
        try {
            bw = new BufferedWriter(new FileWriter("Integer.txt"));
            scanner = new Scanner(System.in);
            String src;
            for (int i = 0; i < 10; i++) {
                System.out.print("请输入第" + (i + 1) + "个数字为：\t");
                src = scanner.nextLine();
                bw.write(src);
                bw.newLine();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(bw != null){
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }
            if(scanner != null){
                scanner.close();
            }
        }
    }
}
